import request from '@/utils/request'

const commonUrl="/admin/product"

//分页查询: GET /admin/product/{page}/{limit}
export function getSpuList({page,limit,category3Id}) {
  return request({
    url: `${commonUrl}/${page}/${limit}`,
    method: 'get',
    params:{category3Id}
  })
}

//获取基础的销售属性 GET /admin/product/baseSaleAttrList
export function getBaseSpuSaleAttrList() {
  return request({
    url: `${commonUrl}/baseSaleAttrList`,
    method: 'get'
  })
}

//根据spuid获取spu对应的销售属性 GET /admin/product/spuSaleAttrList/{spuId}
export function getSpuSaleAttrList(spuId) {
  return request({
    url: `${commonUrl}/spuSaleAttrList/${spuId}`,
    method: 'get'
  })
}

//根据spuid获取spu对应的图片列表 GET /admin/product/spuImageList/{spuId}
export function getSpuImageList(spuId) {
  return request({
    url: `${commonUrl}/spuImageList/${spuId}`,
    method: 'get'
  })
}

//新增 POST /admin/product/saveSpuInfo
//修改 POST /admin/product/updateSpuInfo
export function save(spuInfo) {
  return request({
    url: `${commonUrl}/${spuInfo.id ? "updateSpuInfo":"saveSpuInfo"}`,
    method: 'post',
    data:{
      ...spuInfo
    }
  })
}

//删除spu DELETE /admin/product/deleteSpu/{spuId}
export function del(spuId) {
  return request({
    url: `${commonUrl}/deleteSpu/${spuId}`,
    method: 'delete'
  })
}
